import Vue from 'vue'
import App from './App.vue'
import loginDirective from '@/directives/login.js'
import filtersObj from '@/utils/filter.js'

Vue.use(loginDirective)
import router from './router'
console.log('过滤器对象:', filtersObj);
// 注册全局过滤器
Object.keys(filtersObj).forEach(key => {
  Vue.filter(key, filtersObj[key])
})



// 导入自定义插件/组件
import Notify from '@/components/prompt/prompt.js' // 导入 Notify 插件
import './service/flexible.js' // 适配相关
import '@/assets/iconfont/iconfont.css' // 图标样式
import Toast from '@/components/common/Toast.vue' // Toast 组件

// 注册全局组件
Vue.component('Toast', Toast)

// 挂载全局方法到 Vue 原型
Vue.prototype.$toast = {
  show: (msg, type = 'info', duration = 3000) => {
    const Constructor = Vue.extend(Toast)
    const instance = new Constructor().$mount()
    document.body.appendChild(instance.$el)
    instance.show(msg, type, duration)
  }
}

Vue.use(Notify)

// 创建唯一的 Vue 根实例
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
